package tau.freedbimporter;

import java.util.HashMap;
import java.util.Map;
import java.util.Vector;

public class RawFreeDBDiscInfo {

	private Vector<RawFreeDBTrackInfo> tracks;
	private int discLength;
	private String discID;
	private String title;
	private int year;
	private String genre;
	private String extendedData;
	private Map<String, String> additionalData;

	public RawFreeDBDiscInfo() {
		additionalData = new HashMap<String, String>();
	}
	
	public void setTrackOffsets(Vector<Integer> trackOffsets) {
		tracks = new Vector<RawFreeDBTrackInfo>(trackOffsets.size());
		for (int offset : trackOffsets) {
			RawFreeDBTrackInfo track = new RawFreeDBTrackInfo();
			track.setOffset(offset);
			tracks.add(track);
		}
	}
	
	public void initTrackLengths() {
		int lastTrack = tracks.size() - 1;
		for (int i = 0; i < lastTrack; i++) {
			int length = 
				(tracks.get(i + 1).getOffset() - tracks.get(i).getOffset()) 
				/ 75;
			tracks.get(i).setLength(length);
		}
		
		tracks.get(lastTrack).setLength(discLength - tracks.get(lastTrack).getOffset() / 75);
	}

	public void setTrackTitle(int trackNumber, String title) {
		tracks.get(trackNumber).setTitle(title);
	}

	public void setExtendedTrackData(int trackNumber, String extendedData) {
		tracks.get(trackNumber).setExtendedData(extendedData);
	}

	public int getDiscLength() {
		return discLength;
	}

	public void setDiscLength(int discLength) {
		this.discLength = discLength;
	}

	public String getDiscID() {
		return discID;
	}

	public void setDiscID(String discID) {
		this.discID = discID;
	}
	
	public Vector<RawFreeDBTrackInfo> getTracks() {
		return tracks;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public int getYear() {
		return year;
	}

	public void setYear(int year) {
		this.year = year;
	}

	public String getGenre() {
		return genre;
	}

	public void setGenre(String genre) {
		this.genre = genre;
	}

	public String getExtendedData() {
		return extendedData;
	}

	public void setExtendedData(String extendedData) {
		this.extendedData = extendedData;
	}

	public Map<String, String> getAdditionalData() {
		return additionalData;
	}
	
	public void setAdditionalData(String key, String value) {
		additionalData.put(key, value);
	}

	
}
